package operation;

import book.BookList;

import java.util.Scanner;

public class BorrowOperation extends SearchOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借阅的书名: ");
        String bookName = scanner.nextLine();
        int index = search(bookList, bookName);
        if (index != -1) {
            bookList.getBook(index).setIsBorrowed(true);
            System.out.println("借阅成功!");
        } else {
            System.out.println("未查找到图书《"+bookName+"》!");
        }
    }
}
